package cn.edu.seu.cose.qol.servlet;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
import org.apache.velocity.tools.view.VelocityViewServlet;

@WebServlet("/test")
public class TestServlet extends VelocityViewServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void setContentType(HttpServletRequest request,
			HttpServletResponse response) {
		response.setContentType("text/html;charset=utf-8");
	}
	
	@Override
	protected Template handleRequest(HttpServletRequest request,
			HttpServletResponse response, Context ctx) {
		Map<String, String> ctxMap = new HashMap<String, String>();
		ctxMap.put("a", "rAy1");
		ctxMap.put("b", "rAy2");
		ctx.put("ctxMap", ctxMap);
		return getTemplate("template/index.vm");
	}

}
